﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsForms
{
    class DBHelp
    {
        public static readonly string connect = "server=LAPTOP-AS39K086\\MSSQLSERVER1;uid=HUANG;pwd=571193002;database=WinFrom";

        #region  更新表
        public static DataTable DataTable(string sql) {
            SqlConnection sqlConnection = new SqlConnection(connect);
            sqlConnection.Open();
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql,sqlConnection);
            DataTable dataTable = new DataTable();
            sqlDataAdapter.Fill(dataTable);
            return dataTable;
        }
        #endregion

        #region  修改表
        public static int ChangeSave(string sql) {
            SqlConnection sqlConnection = new SqlConnection(connect);
            sqlConnection.Open();
            SqlCommand sqlCommand = new SqlCommand(sql,sqlConnection);
            return sqlCommand.ExecuteNonQuery();
        }
        #endregion
    }
}
